﻿@model IEnumerable<IMS.DataAccess.Report>
@using IMS.WWW.ControlCenter.Models;
@using ReportSortCriterium = IMS.DataAccess.ReportSortCriterium;
@{
    ViewBag.Title = "Reports";
    var sortBy = (ReportSortCriterium)ViewBag.SortBy;
    var orderBy = (SortDirection)ViewBag.OrderBy;
}

@section Imports {
    <link href="@Url.Content("~/Content/Report.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/report.js")" type="text/javascript"></script>
}

@using (Html.BeginForm()) {
    <div id="date-picker"></div>
    @Html.Hidden("date", new { id = "date" })
}

<table id="report-table">
    <thead>
        <tr>
            <th>
                @if (ViewBag.SortBy == ReportSortCriterium.ByOnSiteOperator) {
                    @Html.ActionLink("Operator", "List", new {
                       sortBy = ReportSortCriterium.ByOnSiteOperator,
                       orderBy = orderBy.Toggle()
                })
                } else {
                    @Html.ActionLink("Operator", "List", new {
                       sortBy = ReportSortCriterium.ByOnSiteOperator,
                       orderBy = SortDirection.Ascending
                    })
                }
            </th>
            <th>
                Location
            </th>
            <th>
                Text
            </th>
            <th>
                @if (ViewBag.SortBy == ReportSortCriterium.ByDate) {
                    @Html.ActionLink("Date", "List", new {
                       sortBy = ReportSortCriterium.ByDate,
                       orderBy = orderBy.Toggle()
                })
                } else {
                    @Html.ActionLink("Date", "List", new {
                       sortBy = ReportSortCriterium.ByDate,
                       orderBy = SortDirection.Descending
                });
                }
            </th>
            <th>
                Time
            </th>
            <th>
            </th>
        </tr>
    </thead>
    <tbody id="report-rows">
@foreach (var item in Model) {
    @Html.DisplayFor(_ => item, "ReportRow")
}
    </tbody>
</table>
